#ifndef CPlane_____
#define CPlane_____

#include "Vector3f.h"

//-----------------------------------------------------------------------------
class CPlane
//-----------------------------------------------------------------------------
{

	// Notes: encapsulation of Ax + By + Cz + D = 0 where A,B,C represent the
	// normal to the plane and D represents the distance from the plane to 
	// the origin when the normal is unit length.

  public:

	//-------------------------------------------------------------------------
	// members
	//-------------------------------------------------------------------------

	vector3f	normal;
	float		D;

	//-------------------------------------------------------------------------
	// constructors
	//-------------------------------------------------------------------------

	CPlane();
	CPlane(vector3f normal_, float D_);

	//-------------------------------------------------------------------------
	// operators
	//-------------------------------------------------------------------------

	bool operator == (const CPlane pl) const;

	//-------------------------------------------------------------------------
	// functions
	//-------------------------------------------------------------------------

	void	PlaneEquation(vector3f a, vector3f b, vector3f c);
	void	Set(const float x_, const float y_, const float z_, 
			    const float D_);
	void	Normalize();
	float	PointToPlaneDistance(const vector3f p);
	bool	PointInFrontOfPlane(const vector3f p);
	bool	PointBehindPlane(const vector3f p);
	bool	PointOnPlane(const vector3f p);
	bool	PointInFrontOrOnPlane(const vector3f p);
	bool	PointOnOrBehindPlane(const vector3f p);
	float	AngleBetweenPlanes(const CPlane pl);

};

#endif